package com.it.gmall.activity.redis;

import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

// redis发布订阅之后需要做的事情放在这个类中
@Component
public class MessageReceive {
    // 接收消息
    public void receiveMessage(String msg){
        // msg => "skuId:0" "skuId:1" => skuId:0 skuId:0
        msg = msg.replaceAll("\"","");
        // [skuId,0] [skuId,1]
        String[] split = msg.split(":");
        // 将状态位放到本地缓存中
        if(null!=split && split.length == 2){
            CacheHelper.put(split[0],split[1]);
        }
    }
}
